feat(settings): add compact agent settings entry - #48
Conversation
|
Warning Review limit reached
Next review available in: 51 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe PR redesigns Agent settings as a compact overview with a nested details page. It adds native Agent settings navigation, manual Dream execution, management cards, localized strings, updated routing and overview behavior, and expanded automated tests and documentation. ChangesAgent settings redesign
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant AgentSidebar
participant DaoAgentUIHandler
participant SettingsRouter
participant AgentPageIndex
participant DaoAgentPage
AgentSidebar->>DaoAgentUIHandler: openAgentSettings
DaoAgentUIHandler->>SettingsRouter: open dao://settings/agent
SettingsRouter->>AgentPageIndex: render compact overview
AgentPageIndex->>SettingsRouter: navigate to /agent
SettingsRouter->>DaoAgentPage: render Agent details
SettingsRouter-->>AgentSidebar: report navigation result
AgentSidebar->>AgentSidebar: close only after success
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/patches/chrome/browser/resources/settings/settings_main/settings_main.ts.patch (1)
142-144: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win仅在概览模式中保存概览滚动位置。
Line 142 只检查搜索词状态。它不检查
overviewMode_。如果用户在DAO_AGENT_DETAILS中开始搜索,此调用会用详情页的滚动位置覆盖已保存的概览位置。后续清除概览搜索时会恢复到错误的位置。建议修改
- if (this.currentQuery_ === '' && query !== '') { + if (this.overviewMode_ && this.currentQuery_ === '' && query !== '') { this.rememberOverviewScroll_(); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/patches/chrome/browser/resources/settings/settings_main/settings_main.ts.patch` around lines 142 - 144, Update the condition in the scroll-saving logic around rememberOverviewScroll_ so it also requires overviewMode_ to be active before saving. Preserve the existing transition check from an empty currentQuery_ to a non-empty query, and prevent searches started in DAO_AGENT_DETAILS from overwriting the saved overview position.src/patches/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc.patch (2)
34-44: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift不要在本地化结果上匹配固定英文文本。
IDS_ABOUT_VERSION_COPYRIGHT已经经过本地化。base::ReplaceSubstringsAfterOffset只替换精确的英文片段The Chromium Authors。当某个语言翻译了该片段时,替换会静默失效,About 页面可能继续显示 Chromium 版权方,而不是MsgByte。请使用带版权方占位符的 Dao 本地化资源。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/patches/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc.patch` around lines 34 - 44, 更新 aboutProductCopyright 的本地化流程,改用包含版权方占位符的 Dao 本地化资源,并通过格式化参数传入 “MsgByte”。移除针对本地化结果中固定英文文本 “The Chromium Authors” 的 ReplaceSubstringsAfterOffset 调用,确保所有语言都显示 MsgByte。
16-16: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win为 Settings C++ 补全 Dao 字符串依赖。
settings_localized_strings_provider.cc新增了dao/browser/strings/grit/dao_strings.h和IDS_DAO_CHECK_FOR_UPDATES_BUTTON使用,但当前补丁只更新了 WebUI 资源 target。Chromium 中该 C++ 文件来自chrome/browser/ui:browser_ui类目标,需要声明//dao/browser/strings:dao_strings依赖;否则构建会缺少dao_strings.h或IDS_DAO_*。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/patches/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc.patch` at line 16, Update the Chromium browser UI target associated with settings_localized_strings_provider.cc to depend on //dao/browser/strings:dao_strings, alongside the existing WebUI resource target updates, so dao_strings.h and IDS_DAO_CHECK_FOR_UPDATES_BUTTON resolve during C++ compilation.
🧹 Nitpick comments (4)
src/patches/chrome/browser/resources/settings/dao_page/dao_agent_page.html.patch (1)
169-210: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsolidate the duplicated card/management action-row and feedback-row styles.
.dao-agent-card-actionsand.dao-agent-card-feedbackduplicate the layout, color, and focus-outline rules of.dao-agent-management-actionsand.dao-agent-management-feedbackalmost line for line. Only the class-name prefix differs.Extract a shared class (or a set of custom properties applied to both selectors) so a future style change, such as the focus-outline color, does not need to be made in two places and cannot silently diverge between the two.
Also applies to: 420-426
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/patches/chrome/browser/resources/settings/dao_page/dao_agent_page.html.patch` around lines 169 - 210, Consolidate the duplicated styles for .dao-agent-card-actions and .dao-agent-card-feedback with the corresponding .dao-agent-management-actions and .dao-agent-management-feedback rules. Introduce shared selectors or custom properties for the common layout, color, spacing, and focus-outline declarations, while preserving each variant’s distinct styling and behavior across both action and feedback rows.src/patches/chrome/test/data/webui/settings/dao_agent_page_test.ts.patch (1)
268-294: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMake
resolveSettingWritehandle anullvalue the same way as the immediate-write path.
setSetting's immediate-write path (lines 141-145) deletes the key fromsnapshot_.valueswhenvalue === null, matching the nativeSetDaoAgentSettingdeletion semantics.resolveSettingWrite, used for the deferred-write path, only updatessnapshot_.valueswhendeferred.value !== null; it never deletes the key whendeferred.value === nullandsuccessistrue.No current test combines
deferSettingWrites()with anullwrite, so this gap is not yet triggered. If a future test exercises a deferred soul-reset (or any other null-value write), the test double would keep the stale value instead of deleting it, unlike production behavior.Add a delete branch to
resolveSettingWritemirroring the immediate-write path.♻️ Proposed fix
resolveSettingWrite(success: boolean): void { const deferred = this.setSettingRequests_.shift(); assertTrue(!!deferred); if (success && deferred.value !== null) { this.snapshot_.values = { ...this.snapshot_.values, [deferred.key]: deferred.value, }; + } else if (success && deferred.value === null) { + const values = {...this.snapshot_.values}; + delete values[deferred.key]; + this.snapshot_.values = values; } deferred.resolve(success); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/patches/chrome/test/data/webui/settings/dao_agent_page_test.ts.patch` around lines 268 - 294, Update resolveSettingWrite to mirror setSetting’s immediate-write semantics: when success is true and deferred.value is null, delete the corresponding key from snapshot_.values; otherwise preserve the existing value-update behavior for non-null values.src/dao/browser/ui/webui/resources/agent/__tests__/dao_agent_app.test.ts (1)
115-127: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win覆盖
{success: false}失败结果。原生处理器在没有活动浏览器时会解析
{success: false},而不是拒绝 Promise。请增加mockResolvedValueOnce({success: false})测试,并确认不会发送closeSidebar。这可覆盖实际的原生失败契约。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/dao/browser/ui/webui/resources/agent/__tests__/dao_agent_app.test.ts` around lines 115 - 127, Extend the sidebar settings failure test around the settings-button click and openAgentSettings callNative invocation to cover a resolved {success: false} response, not only a rejected promise. Assert that this resolved failure also does not trigger send('closeSidebar'), while preserving the existing rejection case.src/patches/chrome/test/data/webui/settings/settings_browsertest.cc.patch (1)
10-23: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift让至少一个 Dao 浏览器测试真正运行。
三个测试都使用
DISABLED_前缀,因此 GoogleTest 不会执行它们。当前代码只保留了测试引用,不验证dao://路由、loader 集成或页面行为。请修复共享 loader 后移除前缀,或增加主动执行的浏览器级替代测试。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/patches/chrome/test/data/webui/settings/settings_browsertest.cc.patch` around lines 10 - 23, Ensure at least one Dao browser test executes by fixing the shared WebUIMochaBrowserTest loader to support Dao’s WebUI scheme, then remove the DISABLED_ prefix from the corresponding SettingsTest case and keep it running via RunTest. Alternatively, add an active browser-level test that validates the dao:// route, loader integration, and page behavior; do not leave all Dao tests disabled.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@design-qa-agent-management-card-title.md`:
- Around line 3-10: Replace the local /var/folders screenshot references in the
“Source visual truth path” and “Implementation screenshot paths” sections with
screenshots stored as version-controlled repository artifacts, then reference
each image using its repository-relative path.
In `@src/dao/browser/agent/dao_agent_settings_handler.cc`:
- Around line 712-744: Update DaoAgentSettingsHandler::HandleStartManualDream to
ensure DaoDreamService has a registered or shared active runner before invoking
StartManualDream. Reuse the existing runner-registration mechanism if available,
and preserve the current callback resolution and rejection behavior once the
runner is ready.
In `@src/patches/chrome/app/resources/generated_resources_zh-CN.xtb.patch`:
- Around line 39-41: 将翻译条目 4693970697348136016
从“恢复默认设置”改为仅表达“恢复默认人格”,与相邻的默认人格成功和失败文案保持一致;不要修改另外两个翻译条目。
- Line 4: 更新 generated_resources_zh-CN.xtb.patch 中的资源条目,使其与
settings_strings.grdp.patch 新增的
IDS_SETTINGS_BROWSER_GROUP、IDS_SETTINGS_DAO_AGENT_PROVIDER_LABEL、IDS_SETTINGS_DAO_AGENT_MODEL_LABEL
和 IDS_SETTINGS_DAO_AGENT_CONTEXT_TITLE 保持一致;使用 GRIT 或生成的资源头核对准确
ID,并为这些资源补充对应的中文翻译,避免界面回退到英文源文本。
In
`@src/patches/chrome/browser/resources/settings/dao_page/dao_agent_page.ts.patch`:
- Around line 726-739: Update setAgentSetting_ to catch rejections from
agentSettingsBrowserProxy_.setSetting and convert them into a false result,
while preserving the existing value-update behavior only for accepted settings.
---
Outside diff comments:
In
`@src/patches/chrome/browser/resources/settings/settings_main/settings_main.ts.patch`:
- Around line 142-144: Update the condition in the scroll-saving logic around
rememberOverviewScroll_ so it also requires overviewMode_ to be active before
saving. Preserve the existing transition check from an empty currentQuery_ to a
non-empty query, and prevent searches started in DAO_AGENT_DETAILS from
overwriting the saved overview position.
In
`@src/patches/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc.patch`:
- Around line 34-44: 更新 aboutProductCopyright 的本地化流程,改用包含版权方占位符的 Dao
本地化资源,并通过格式化参数传入 “MsgByte”。移除针对本地化结果中固定英文文本 “The Chromium Authors” 的
ReplaceSubstringsAfterOffset 调用,确保所有语言都显示 MsgByte。
- Line 16: Update the Chromium browser UI target associated with
settings_localized_strings_provider.cc to depend on
//dao/browser/strings:dao_strings, alongside the existing WebUI resource target
updates, so dao_strings.h and IDS_DAO_CHECK_FOR_UPDATES_BUTTON resolve during
C++ compilation.
---
Nitpick comments:
In `@src/dao/browser/ui/webui/resources/agent/__tests__/dao_agent_app.test.ts`:
- Around line 115-127: Extend the sidebar settings failure test around the
settings-button click and openAgentSettings callNative invocation to cover a
resolved {success: false} response, not only a rejected promise. Assert that
this resolved failure also does not trigger send('closeSidebar'), while
preserving the existing rejection case.
In
`@src/patches/chrome/browser/resources/settings/dao_page/dao_agent_page.html.patch`:
- Around line 169-210: Consolidate the duplicated styles for
.dao-agent-card-actions and .dao-agent-card-feedback with the corresponding
.dao-agent-management-actions and .dao-agent-management-feedback rules.
Introduce shared selectors or custom properties for the common layout, color,
spacing, and focus-outline declarations, while preserving each variant’s
distinct styling and behavior across both action and feedback rows.
In `@src/patches/chrome/test/data/webui/settings/dao_agent_page_test.ts.patch`:
- Around line 268-294: Update resolveSettingWrite to mirror setSetting’s
immediate-write semantics: when success is true and deferred.value is null,
delete the corresponding key from snapshot_.values; otherwise preserve the
existing value-update behavior for non-null values.
In `@src/patches/chrome/test/data/webui/settings/settings_browsertest.cc.patch`:
- Around line 10-23: Ensure at least one Dao browser test executes by fixing the
shared WebUIMochaBrowserTest loader to support Dao’s WebUI scheme, then remove
the DISABLED_ prefix from the corresponding SettingsTest case and keep it
running via RunTest. Alternatively, add an active browser-level test that
validates the dao:// route, loader integration, and page behavior; do not leave
all Dao tests disabled.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 4f4ab913-72ca-445b-9238-562de6f583cf
📒 Files selected for processing (33)
design-qa-agent-management-card-title.mddocs/feature-checklist.mddocs/features.mdscripts/commands/__tests__/settings_i18n.test.tsscripts/commands/__tests__/settings_redesign_contract.test.tssrc/dao/browser/agent/dao_agent_settings_handler.ccsrc/dao/browser/agent/dao_agent_settings_handler.hsrc/dao/browser/agent/dao_agent_settings_handler_unittest.ccsrc/dao/browser/ui/views/dao_browser_browsertest.ccsrc/dao/browser/ui/webui/dao_agent_ui.ccsrc/dao/browser/ui/webui/dao_agent_ui.hsrc/dao/browser/ui/webui/resources/agent/__tests__/dao_agent_app.test.tssrc/dao/browser/ui/webui/resources/agent/dao_agent_app.tssrc/patches/chrome/app/resources/generated_resources_zh-CN.xtb.patchsrc/patches/chrome/app/settings_strings.grdp.patchsrc/patches/chrome/browser/resources/settings/BUILD.gn.patchsrc/patches/chrome/browser/resources/settings/dao_page/dao_agent_page.html.patchsrc/patches/chrome/browser/resources/settings/dao_page/dao_agent_page.ts.patchsrc/patches/chrome/browser/resources/settings/dao_page/dao_agent_page_index.html.patchsrc/patches/chrome/browser/resources/settings/dao_page/dao_agent_page_index.ts.patchsrc/patches/chrome/browser/resources/settings/dao_page/dao_agent_settings_browser_proxy.ts.patchsrc/patches/chrome/browser/resources/settings/route.ts.patchsrc/patches/chrome/browser/resources/settings/router_dao.ts.patchsrc/patches/chrome/browser/resources/settings/settings.ts.patchsrc/patches/chrome/browser/resources/settings/settings_main/settings_main.html.patchsrc/patches/chrome/browser/resources/settings/settings_main/settings_main.ts.patchsrc/patches/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc.patchsrc/patches/chrome/test/data/webui/settings/BUILD.gn.patchsrc/patches/chrome/test/data/webui/settings/dao_agent_page_index_test.ts.patchsrc/patches/chrome/test/data/webui/settings/dao_agent_page_test.ts.patchsrc/patches/chrome/test/data/webui/settings/settings_browsertest.cc.patchsrc/patches/chrome/test/data/webui/settings/settings_main_test.ts.patchsrc/patches/chrome/test/data/webui/settings/settings_menu_test.ts.patch
| **Source visual truth path** | ||
|
|
||
| `/var/folders/0l/4dc990md3yn_g3b46dtmhp880000gn/T/orca-paste-1786355815911-c1768617-d9d5-4b7c-bc02-17762b0964a4.png` | ||
|
|
||
| **Implementation screenshot paths** | ||
|
|
||
| - Memory and Workspace: `/var/folders/0l/4dc990md3yn_g3b46dtmhp880000gn/T/orca-computer-use/8319c5ab-6c27-406a-b73d-46545f9b40f0-screenshot.png` | ||
| - Usage: `/var/folders/0l/4dc990md3yn_g3b46dtmhp880000gn/T/orca-computer-use/4239e809-2f34-4949-be50-d3d161209a31-screenshot.png` |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
使用仓库可访问的视觉证据路径。
这些 /var/folders/... 路径是本机临时文件路径。合并后,审阅者和 CI 无法访问截图。将截图作为受版本控制的工件保存,并使用仓库相对路径引用它们。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@design-qa-agent-management-card-title.md` around lines 3 - 10, Replace the
local /var/folders screenshot references in the “Source visual truth path” and
“Implementation screenshot paths” sections with screenshots stored as
version-controlled repository artifacts, then reference each image using its
repository-relative path.
| void DaoAgentSettingsHandler::HandleStartManualDream( | ||
| const base::ListValue& args) { | ||
| AllowJavascript(); | ||
| if (args.size() != 1 || !args[0].is_string()) { | ||
| return; | ||
| } | ||
| const std::string callback_id = args[0].GetString(); | ||
| Profile* profile = Profile::FromWebUI(web_ui()); | ||
| DaoDreamService* service = | ||
| profile ? DaoDreamServiceFactory::GetForProfile(profile) : nullptr; | ||
| if (!service) { | ||
| RejectJavascriptCallback(base::Value(callback_id), | ||
| base::Value("dream service unavailable")); | ||
| return; | ||
| } | ||
| service->StartManualDream(base::BindOnce( | ||
| [](base::WeakPtr<DaoAgentSettingsHandler> handler, | ||
| std::string callback_id, bool success, const std::string& error) { | ||
| if (!handler) { | ||
| return; | ||
| } | ||
| if (success) { | ||
| handler->ResolveJavascriptCallback(base::Value(callback_id), | ||
| base::Value(true)); | ||
| return; | ||
| } | ||
| handler->RejectJavascriptCallback( | ||
| base::Value(callback_id), | ||
| base::Value(error.empty() ? "dream run failed" : error)); | ||
| }, | ||
| weak_factory_.GetWeakPtr(), callback_id)); | ||
| } | ||
|
|
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Inspect DaoDreamService's SetRunner/StartManualDream contract
# and confirm the settings browser proxy sends the matching message name.
fd -i dao_dream_service | while IFS= read -r file; do
echo "=== $file ==="
rg -n -A 15 -B 2 'SetRunner|StartManualDream' "$file"
done
fd -i dao_agent_settings_browser_proxy | while IFS= read -r file; do
echo "=== $file ==="
rg -n -A 5 -B 2 'startManualDaoDream|startManualDream' "$file"
doneRepository: msgbyte/dao-browser
Length of output: 3678
🏁 Script executed:
#!/bin/bash
# Inspect StartManualDreamForDate flow and the corresponding runner path.
file="src/dao/browser/agent/dao_dream_service.cc"
rg -n -A 80 -B 10 'StartManualDreamForDate\(' "$file"
rg -n -A 80 -B 30 'StartManualDream.*Runner|RunDream|ExecuteDream|Runner' "$file" | head -n 240Repository: msgbyte/dao-browser
Length of output: 13355
Set a runner before starting the manual Dream from Settings.
DaoDreamService::StartManualDreamForDate fails when runner_ is null and returns agent webui unavailable; later collection also requires runner_ for RunDream(). Add this handler’s runner registration or share an existing active runner before calling StartManualDream. The browser proxy message name already matches "startManualDaoDream".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/dao/browser/agent/dao_agent_settings_handler.cc` around lines 712 - 744,
Update DaoAgentSettingsHandler::HandleStartManualDream to ensure DaoDreamService
has a registered or shared active runner before invoking StartManualDream. Reuse
the existing runner-registration mechanism if available, and preserve the
current callback resolution and rejection behavior once the runner is ready.
| --- a/chrome/app/resources/generated_resources_zh-CN.xtb | ||
| +++ b/chrome/app/resources/generated_resources_zh-CN.xtb | ||
| @@ -1,6 +1,114 @@ | ||
| @@ -1,6 +1,122 @@ |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
header="$(fd --type f --full-path 'chrome/grit/generated_resources\.h$' . | head -n1 || true)"
xtb="$(fd --type f --full-path 'chrome/app/resources/generated_resources_zh-CN\.xtb$' . | head -n1 || true)"
test -n "$header" && test -n "$xtb"
python - "$header" "$xtb" <<'PY'
import re
import sys
from pathlib import Path
header = Path(sys.argv[1]).read_text()
xtb = Path(sys.argv[2]).read_text()
names = [
"IDS_SETTINGS_BROWSER_GROUP",
"IDS_SETTINGS_DAO_AGENT_PROVIDER_LABEL",
"IDS_SETTINGS_DAO_AGENT_MODEL_LABEL",
"IDS_SETTINGS_DAO_AGENT_CONTEXT_TITLE",
]
missing = []
for name in names:
match = re.search(rf"\b{name}\b[^0-9]*(\d+)", header)
if not match:
raise SystemExit(f"Missing generated resource ID for {name}")
resource_id = match.group(1)
if f'id="{resource_id}"' not in xtb:
missing.append(f"{name} ({resource_id})")
if missing:
raise SystemExit("Missing zh-CN translations:\n" + "\n".join(missing))
PYRepository: msgbyte/dao-browser
Length of output: 679
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Tracked generated_resources.h candidates:"
git ls-files | rg '(^|/)chrome/grit/generated_resources\.h$|generated_resources\.h$' || true
echo "Tracked zh-CN XTB candidates:"
git ls-files | rg 'generated_resources_zh-CN\.xtb$|zh-CN/.*\.xtb$' || true
echo "Patch files:"
git ls-files | rg '(^|/)src/patches/.*\.patch$' || trueRepository: msgbyte/dao-browser
Length of output: 14688
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "settings_strings patch relevant resources:"
sed -n '1,220p' src/patches/chrome/app/settings_strings.grdp.patch | rg -n -i 'IDS_SETTINGS_BROWSER_GROUP|IDS_SETTINGS_DAO_AGENT_PROVIDER_LABEL|IDS_SETTINGS_DAO_AGENT_MODEL_LABEL|IDS_SETTINGS_DAO_AGENT_CONTEXT_TITLE|<string name=' -C 3 || true
echo "generated_resources zh-CN patch entry count and nearby IDs:"
wc -l src/patches/chrome/app/resources/generated_resources_zh-CN.xtb.patch
rg -n 'IDR_SETTINGS_|IDS_SETTINGS_BROWSER_GROUP|IDS_SETTINGS_DAO_AGENT_PROVIDER_LABEL|IDS_SETTINGS_DAO_AGENT_MODEL_LABEL|IDS_SETTINGS_DAO_AGENT_CONTEXT_TITLE|<message.+name=' src/patches/chrome/app/resources/generated_resources_zh-CN.xtb.patch -C 2 || true
echo "dao_page ts/html resource IDs:"
for f in src/patches/chrome/browser/resources/settings/dao_page/dao_agent_page.ts.patch src/patches/chrome/browser/resources/settings/dao_page/dao_agent_page.html.patch src/patches/chrome/browser/resources/settings/dao_page/dao_agent_page_index.html.patch src/patches/chrome/browser/resources/settings/dao_page/dao_agent_page_index.ts.patch; do
echo "--- $f"
rg -n 'IDs\.(IDS_SETTINGS_[A-Z0-9_]+)|SettingsStringsProvider\.initializeLocalizedStrings|chrome\.i18n\.' "$f" -C 2 || true
doneRepository: msgbyte/dao-browser
Length of output: 1133
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import re
settings_patch = Path("src/patches/chrome/app/settings_strings.grdp.patch").read_text()
xtb_patch = Path("src/patches/chrome/app/resources/generated_resources_zh-CN.xtb.patch").read_text()
# Extract all new <message name=...> entries added by settings_strings.grdp.patch.
new_messages = []
for line in settings_patch.splitlines():
if line.startswith("+ <message name="):
m = re.search(r'<message name="([^"]+)"', line)
if m:
new_messages.append(m.group(1))
# Find corresponding entry in generated_resources_zh-CN.xtb.patch by id/name or content.
# XTBS from Chrome are typically generated as <message name="GENERATED_RESOURCE_ID" ...>.
missing = []
for name in new_messages:
# Commonly generated XTB entry for a message ID uses GENERATED_RESOURCE_ID for the generated id.
# Also match if an XTB entry's English source in patch is same, since generated_resources_grdp is input.
found_by_generated = bool(re.search(rf'id="GENERATED_RESOURCE_ID_[A-Z0-9_]+"' .* f'GENERATED_FILE=".*{re.escape(name)}"'), xtb_patch))
found_by_id_prefix = False
for id_str in extract_names_to_ids(settings_patch):
if f'id="GENERATED_RESOURCE_ID_{resource_id}"' in xtb_patch:
found_by_id_prefix = True
break
missing.append(name if not found_by_generated else None)
PY
# Actually inspect exact patches around new DAO settings.
sed -n '170,270p' src/patches/chrome/app/settings_strings.grdp.patch
sed -n '1,260p' src/patches/chrome/app/resources/generated_resources_zh-CN.xtb.patchRepository: msgbyte/dao-browser
Length of output: 435
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import re
settings_patch = Path("src/patches/chrome/app/settings_strings.grdp.patch").read_text()
xtb_patch = Path("src/patches/chrome/app/resources/generated_resources_zh-CN.xtb.patch").read_text()
new_ids = re.findall(r'\s+(IDS_[A-Z0-9_]+)\s+\d+', settings_patch)
target_names = [
"IDS_SETTINGS_BROWSER_GROUP",
"IDS_SETTINGS_DAO_AGENT_PROVIDER_LABEL",
"IDS_SETTINGS_DAO_AGENT_MODEL_LABEL",
"IDS_SETTINGS_DAO_AGENT_CONTEXT_TITLE",
]
target_ids = sorted(set(new_ids) & set(target_names))
xtb_ids = sorted(set(re.findall(r'id="([^"]+)"', xtb_patch)))
print("target ids:", target_ids)
print("matching ids in generated_resources_zh-CN.xtb.patch:")
for name in target_ids:
found = any(id_str in xtb_patch for id_str in target_ids)
print(f"{name}: {'yes' if found else 'no'}")
print("generated_resources_zh-CN.xtb.patch IDs count:", len(xtb_ids))
print("first 60 XTB IDs:")
for i, id_str in enumerate(xtb_ids[:60], 1):
print(f"{i}: {id_str}")
PY
echo "--- generated_resources_zh-CN.xtb.patch lines 1-260 ---"
sed -n '1,260p' src/patches/chrome/app/resources/generated_resources_zh-CN.xtb.patch
echo "--- settings_strings.grdp.patch lines 150-260 ---"
sed -n '150,260p' src/patches/chrome/app/settings_strings.grdp.patchRepository: msgbyte/dao-browser
Length of output: 26777
🌐 Web query:
Chromium GRDP generated_resources_zh-CN.xtb message name generated resource ID
💡 Result:
In the Chromium project, files like generated_resources_zh-CN.xtb are Translation Bundle (XTB) files that store localized strings [1][2]. These files are integral to the project's UI localization system, which is managed by the GRIT (Google Resource and Identifiers Tool) utility [1][3]. The relationship between the message name (defined in.grd/.grdp files) and the generated resource ID in an.xtb file is as follows: 1. Resource IDs in XTB Files: Each element within an.xtb file contains a numeric id attribute (e.g., ...) [4]. These numeric IDs are generated by GRIT [5]. 2. Linkage to Message Names: The message name (such as IDS_EXAMPLE_STRING) is defined in a.grd or.grdp file [6][3]. When GRIT processes these files, it assigns a unique numeric ID to each message name [5]. 3. Generation Process: GRIT maps the original English strings (from the.grd files) to these unique numeric IDs and exports them into an.xmb format for external translation [5][2]. After external translation, the resulting strings are packaged back into.xtb files, maintaining the same numeric IDs generated during the initial build phase [5][2]. 4. Stability: The numeric IDs are stable for a given string once assigned, allowing the build system to correctly associate the translated text in the.xtb file with the specific message name used in the C++/UI code [5][1]. To determine the ID associated with a specific message name, you can examine the generated header files (e.g., generated_resources.h) produced by the build process, which map the C++ constant (message name) to its corresponding integer resource ID [7][1]. The.xtb files simply act as a database that maps these pre-assigned numeric IDs to their translated content for various locales [1][2].
Citations:
- 1: https://www.chromium.org/developers/tools-we-use-in-chromium/grit/grit-users-guide/
- 2: https://www.chromium.org/developers/tools-we-use-in-chromium/grit/grit-design-overview/
- 3: https://www.chromium.org/developers/design-documents/ui-localization/
- 4: https://chromium.googlesource.com/chromium/src/+/24eaf090c6..8eb8e09f19
- 5: https://groups.google.com/a/chromium.org/g/chromium-dev/c/BINnPtEMgSw
- 6: https://chromium.googlesource.com/chromium/src/+/8cf6737db647761c35fba04893373d616d296314/chrome/app/generated_resources.grd
- 7: https://chromium.googlesource.com/chromium/src/+/HEAD/base/win/embedded_i18n/create_string_rc.py
🌐 Web query:
Chrome GRDP resource IDs generated_resources_zh-CN.xtb generated resource ID hash message source
💡 Result:
In the Chromium project, resources are managed by a tool called GRIT (Google Resource and Identity Tool). Files ending in.xtb (like generated_resources_zh-CN.xtb) are XML Translation Bundles that contain localized string translations for messages defined in corresponding.grd (GRD resource) files [1][2][3]. Resource IDs are not statically hardcoded into these files. Instead, they are dynamically generated during the build process to ensure uniqueness across the entire codebase [1][4][5]. The system for managing these IDs functions as follows: 1. Resource ID Assignment: The central coordination for these IDs is handled by files located in tools/gritsettings/, specifically resource_ids.spec [1][5][6]. This specification file assigns fake start IDs to various.grd files to establish a relative ordering and structure [1][3][7]. 2. Automatic Generation: GRIT uses the ordering defined in resource_ids.spec (or a generated resource_ids file) to assign actual, unique integer IDs during the build [1][5][7]. For static.grd files, the tool parses the number of resources to determine the required range of IDs [1][3][5]. 3. Generated Files: For generated.grd files, where the exact number of resources may not be known at parse time, the system uses a META field (such as "sizes") in resource_ids.spec to reserve a sufficient range of IDs [1][5][7]. 4. Translation Files (.xtb): The.xtb files contain translations linked to messages defined in the.grd files. The relationship is maintained via unique message names or IDs; when GRIT processes these files, it maps the translated strings from the.xtb file back to the resources using the dynamically assigned IDs [1][2][3]. In summary, the resource ID is a transient, build-time construct assigned by the GRIT build system based on an ordering specification, rather than a value embedded within the.xtb translation source itself [1][4][5].
Citations:
- 1: https://chromium.googlesource.com/chromium/src/+/HEAD/tools/gritsettings/
- 2: https://chromium.googlesource.com/chromium/src.git/+/62.0.3178.1/tools/gritsettings/README.md
- 3: https://chromium.googlesource.com/chromium/src/+/e79a4e25dc232fd074dff9a7b159f6558f8d8e31/tools/gritsettings/README.md
- 4: https://chromium.googlesource.com/chromium/src/+/c01049cdca606bab7f0ad9fa65d6ffb8bd0569d6/tools/gritsettings/
- 5: https://chromium.googlesource.com/chromium/src.git/+show/c51b2f4ac0c2581ee0c0f15392331dd4959cbdf7/tools/gritsettings/README.md
- 6: https://chromium.googlesource.com/chromium/src.git/+/b846067dcb8e1024449a9682761a4867b85140a7/tools/gritsettings/resource_ids.spec
- 7: https://chromium.googlesource.com/chromium/src/+show/ae3143abb013464882b25c5ad5b5a569c21e596c/tools/gritsettings/README.md
🌐 Web query:
site:chromium.googlesource.com generated_resources.h IDS_SETTINGS_DAO_AGENT_PROVIDER_LABEL
💡 Result:
The identifier IDS_SETTINGS_DAO_AGENT_PROVIDER_LABEL is a resource string constant used within the Chromium codebase [1][2]. In Chromium, resource identifiers prefixed with IDS_ typically refer to localized user-facing strings defined in GRIT (Google Resource and Interface Toolkit) files [1][3][2]. These identifiers are compiled into a generated header file (such as generated_resources.h) to allow C++ code to reference the string by a symbolic name rather than a raw index [2]. Based on its name, this specific identifier relates to settings (SETTINGS), likely within a Data Access Object (DAO) or similar pattern (DAO), and pertains to a label (LABEL) for an agent provider (AGENT_PROVIDER). In the context of Chromium's settings architecture, such constants are frequently used to provide UI labels for various service or search providers in settings menus, search engine management pages, or other configuration interfaces [4][5][6]. If you are looking for this specific string in your local codebase, it will be defined in one of the.grd or.grdp files (such as chrome/app/settings_strings.grdp or similar) and generated into the header file during the build process [7][1][2].
Citations:
- 1: https://chromium.googlesource.com/chromium/src/+/d2af662cd05d4c85b9d4936b4bb02ef67a952418/chrome/app/generated_resources.grd
- 2: https://chromium.googlesource.com/chromium/src/+/2e43be4e0cb5f43d721f31ef75a27671d3a26cf0/chrome/app/BUILD.gn
- 3: https://chromium.googlesource.com/chromium/src/+/main/tools/gritsettings/resource_ids.spec
- 4: https://chromium.googlesource.com/chromium/src/+/master/chrome/browser/ui/webui/settings/search_engines_handler.cc
- 5: https://chromium.googlesource.com/chromium/src/+/refs/tags/141.0.7390.111/components/search_engines/default_search_manager.h
- 6: https://chromium.googlesource.com/chromium/src/+/c91a183350569adaff5329376fe6ae27f2a2606d/chrome/android/java/src/org/chromium/chrome/browser/settings/search/SettingsSearchCoordinator.java
- 7: https://chromium.googlesource.com/chromium/src.git/+/55823cddbfc827a7e366b2027986143a2b230116/chrome/app/settings_strings.grdp
🌐 Web query:
Chrome generated_resources_zh-CN.xtb generated resource IDs source hash of English text
💡 Result:
In the Chromium translation system, XTB files (such as generated_resources_zh-CN.xtb) are XML-based translation bundles that contain localized versions of UI strings [1][2][3]. The translation IDs used in these files are numeric identifiers calculated as a hash of the original en-US string from the associated GRD file [4][1][2]. This hashing mechanism allows the build system to correlate a specific translation in an XTB file with the correct source string in the GRD file, even if the strings are reordered or moved [2]. Technical details regarding this ID generation can be found in the Chromium source tree, specifically within the GRIT (Google Resource and Interface Tool) utility, which manages the localization process [1][5]. For instance, historical references point to the ID generation logic being handled by functions such as GenerateId located in the tools/grit directory [1]. The overall localization workflow in Chromium functions as follows: 1. Base strings are defined in en-US within.grd or.grdp files [6][3]. 2. GRIT processes these files to create.xmb files (an intermediate format) [1]. 3. An internal, automated Google localization process translates these strings and packages them into.xtb files [6][1][3]. 4. These.xtb files are subsequently checked back into the Chromium source repository, often periodically or before release branch points, to be used by the build system [1][3][7]. Developers working on Chromium or derivative browsers must ensure that if they add new strings requiring translation, they include placeholder.xtb files in the repository to prevent build failures, as the system expects these files to be present during the compilation process [6][3].
Citations:
- 1: https://groups.google.com/a/chromium.org/g/chromium-dev/c/BINnPtEMgSw
- 2: https://yngve.vivaldi.net/the-trouble-with-chromium-translations/
- 3: https://www.chromium.org/developers/design-documents/ui-localization/
- 4: https://blog.51cto.com/u_14555/13709949
- 5: https://www.chromium.org/developers/tools-we-use-in-chromium/grit/grit-users-guide/
- 6: https://chromium.googlesource.com/playground/chromium-org-site/+/refs/heads/main/developers/design-documents/ui-localization/index.md
- 7: https://chromium.googlesource.com/chromium/src/+/acd4dae52877c8dbba435d03931d4605d7bed3ed
🌐 Web query:
site:github.com chromium src generated_resources_zh-CN.xtb translation id hash source string
💡 Result:
In the Chromium source tree, translation IDs used in XTB files (such as generated_resources_zh-CN.xtb) are not based on the string content itself, but are generated from the unique message text associated with each resource ID defined in the.grd (GRIT) files [1][2]. The mechanism for generating these IDs is implemented within the Chromium GRIT (Google Resource and Interface Tool) framework, specifically via a function called GenerateMessageId [1][2]. This function computes a numeric hash of the source string (the English message) to create a unique identifier [1]. Because multiple different resource IDs might occasionally share the same English message text, the message ID is often mapped to a list of resource IDs rather than a one-to-one relationship [1]. Key technical points include: 1. Identification Mechanism: The numeric IDs found in XTB files correspond to these hashes [1][3]. If you modify a string in a.grd file, its corresponding hash (and thus its translation ID) will change, requiring an update to the associated XTB files [2]. 2. Tools: Chromium developers use specific scripts to manage these IDs. The GRIT toolset is the authoritative source for this logic [1][2]. There are also third-party tools, such as tranid, designed to assist developers in generating or looking up these translation IDs from.grd files [3]. 3. Workflow: When new strings are added or existing strings are updated in.grd files, the build system or developer scripts (like those found in tools/grit/ or custom update scripts) re-calculate these message IDs to ensure the translation files remain synchronized [1][2]. For exact implementation details, you can reference the GRIT source code at tools/grit/grit/extern/tclib.py (where GenerateMessageId is typically defined) [2].
Citations:
- 1: https://github.com/dvalter/chromium-android-ext-dev/blob/kiwi-patches/base/win/embedded_i18n/create_string_rc.py
- 2: https://github.com/ecosia/chromium-android-browser/blob/ecosia-129.0.6668.112-squashed/README.md
- 3: https://github.com/zhsoft88/tranid
需要补全 DAO settings 相关 XTB 翻译。
settings_strings.grdp.patch 新增了 IDS_SETTINGS_BROWSER_GROUP、IDS_SETTINGS_DAO_AGENT_PROVIDER_LABEL、IDS_SETTINGS_DAO_AGENT_MODEL_LABEL 和 IDS_SETTINGS_DAO_AGENT_CONTEXT_TITLE 等资源,但 generated_resources_zh-CN.xtb.patch 中的资源 ID 与这些新增资源不一致。使用 GRIT/生成的资源头确认具体 ID 后,在 zh-CN XTB 补齐对应中文条目;缺失时,dao 设置界面的这些文案会 fallback 到英文源文本。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/patches/chrome/app/resources/generated_resources_zh-CN.xtb.patch` at line
4, 更新 generated_resources_zh-CN.xtb.patch 中的资源条目,使其与 settings_strings.grdp.patch
新增的
IDS_SETTINGS_BROWSER_GROUP、IDS_SETTINGS_DAO_AGENT_PROVIDER_LABEL、IDS_SETTINGS_DAO_AGENT_MODEL_LABEL
和 IDS_SETTINGS_DAO_AGENT_CONTEXT_TITLE 保持一致;使用 GRIT 或生成的资源头核对准确
ID,并为这些资源补充对应的中文翻译,避免界面回退到英文源文本。
| +<translation id="4693970697348136016">恢复默认设置</translation> | ||
| +<translation id="5161348942162404027">已恢复默认人格</translation> | ||
| +<translation id="446536169863196969">无法恢复默认人格。</translation> |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
将重置操作限定为“默认人格”。
源资源 IDS_SETTINGS_DAO_AGENT_SOUL_RESET 只重置 Agent persona。当前翻译“恢复默认设置”表示重置全部设置,与相邻的“默认人格”成功和失败文案不一致。
建议翻译
-<translation id="4693970697348136016">恢复默认设置</translation>
+<translation id="4693970697348136016">恢复默认人格</translation>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| +<translation id="4693970697348136016">恢复默认设置</translation> | |
| +<translation id="5161348942162404027">已恢复默认人格</translation> | |
| +<translation id="446536169863196969">无法恢复默认人格。</translation> | |
| <translation id="4693970697348136016">恢复默认人格</translation> | |
| <translation id="5161348942162404027">已恢复默认人格</translation> | |
| <translation id="446536169863196969">无法恢复默认人格。</translation> |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/patches/chrome/app/resources/generated_resources_zh-CN.xtb.patch` around
lines 39 - 41, 将翻译条目 4693970697348136016
从“恢复默认设置”改为仅表达“恢复默认人格”,与相邻的默认人格成功和失败文案保持一致;不要修改另外两个翻译条目。
| + private async setAgentSetting_(key: string, value: string|null) { | ||
| + const accepted = await this.agentSettingsBrowserProxy_.setSetting( | ||
| + key, value); | ||
| + if (accepted && value !== null) { | ||
| + if (!accepted) { | ||
| + return false; | ||
| + } | ||
| + if (value === null) { | ||
| + const values = {...this.agentSettingsValues_}; | ||
| + delete values[key]; | ||
| + this.agentSettingsValues_ = values; | ||
| + } else { | ||
| + this.agentSettingsValues_ = {...this.agentSettingsValues_, [key]: value}; | ||
| + } | ||
| + return true; |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
将 rejected 设置写入转换为失败结果。
setAgentSetting_ 只在已解析的 false 时返回失败。setSetting() 拒绝时会使 Promise 逸出。onAgentBooleanSettingChange_ 等调用方使用 void 调用该方法,因此会产生未处理的 rejection。请在 setAgentSetting_ 中捕获 rejection 并返回 false。
Proposed fix
private async setAgentSetting_(key: string, value: string|null) {
- const accepted = await this.agentSettingsBrowserProxy_.setSetting(
- key, value);
+ let accepted: boolean;
+ try {
+ accepted = await this.agentSettingsBrowserProxy_.setSetting(key, value);
+ } catch {
+ return false;
+ }
if (!accepted) {
return false;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| + private async setAgentSetting_(key: string, value: string|null) { | |
| + const accepted = await this.agentSettingsBrowserProxy_.setSetting( | |
| + key, value); | |
| + if (accepted && value !== null) { | |
| + if (!accepted) { | |
| + return false; | |
| + } | |
| + if (value === null) { | |
| + const values = {...this.agentSettingsValues_}; | |
| + delete values[key]; | |
| + this.agentSettingsValues_ = values; | |
| + } else { | |
| + this.agentSettingsValues_ = {...this.agentSettingsValues_, [key]: value}; | |
| + } | |
| + return true; | |
| private async setAgentSetting_(key: string, value: string|null) { | |
| let accepted: boolean; | |
| try { | |
| accepted = await this.agentSettingsBrowserProxy_.setSetting(key, value); | |
| } catch { | |
| return false; | |
| } | |
| if (!accepted) { | |
| return false; | |
| } | |
| if (value === null) { | |
| const values = {...this.agentSettingsValues_}; | |
| delete values[key]; | |
| this.agentSettingsValues_ = values; | |
| } else { | |
| this.agentSettingsValues_ = {...this.agentSettingsValues_, [key]: value}; | |
| } | |
| return true; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@src/patches/chrome/browser/resources/settings/dao_page/dao_agent_page.ts.patch`
around lines 726 - 739, Update setAgentSetting_ to catch rejections from
agentSettingsBrowserProxy_.setSetting and convert them into a false result,
while preserving the existing value-update behavior only for accepted settings.
027218a to
5121deb
Compare
Background
This change moves Agent settings out of the continuous overview form into a compact Settings overview entry, while keeping the full Agent configuration available as a dedicated secondary page at
dao://settings/agent.Changes
dao://settings/agentthrough a native command and close the sidebar only after navigation succeeds.Testing
Patch includes updated Settings i18n and redesign contract tests, Agent WebUI tests, Agent settings handler unit coverage, Settings WebUI test patches, and a browser test for Agent gear navigation.
Summary by CodeRabbit
New Features
Bug Fixes